﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ECCIT.Utilities;
using OgilvyOne.BLL;
using OgilvyOne.Model;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;

public partial class GateService_CommonAjax : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if(!IsPostBack)
        {
            var requestCmd = Request.QueryString["cmd"] ?? string.Empty;
            switch (requestCmd)
            {
                case "SelectProvices":
                    IList<DictionaryManageModel> list =
                        new DictionaryManageBLL().GetDictionary(int.Parse(CommonConst.ProviceColumnID)).Cast
                            <DictionaryManageModel>().ToList();
                    if(list.Count>0)
                    {
                        var mm = JsonUtil.Serialize(list);
                        ResponseJson(JsonUtil.Serialize(list));
                    }
                    break;
                case "SelectCity":
                    var tt = Request.QueryString["proviceid"];
                    var proviceid = Request.QueryString["proviceid"] != null
                                        ? int.Parse(Request.QueryString["proviceid"])
                                        : 0;
                    IList<DictionaryManageModel> listcity =
                        new DictionaryManageBLL().GetDictionary(proviceid).Cast
                            <DictionaryManageModel>().ToList();
                    if (listcity.Count > 0)
                    {
                        ResponseJson(JsonUtil.Serialize(listcity));
                    }
                    break;
                case "SelectInterests":
                    var lanagerid = Request.QueryString["lanagerid"] != null
                                        ? int.Parse(Request.QueryString["lanagerid"])
                                        : 1033;
                    IList<ArtFormModel> artlist = new ArtFormBLL(lanagerid).SelectArtForms();
                    if (artlist.Count>0)
                    {
                        ResponseJson(JsonUtil.Serialize(artlist));
                    }
                    break;
            }
        }

    }

    private void ResponseJson(string content)
    {
        Response.Write(content);
    }
}